home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / hardware / cpu115 / smm.asm < prev    next >
Assembly Source File  |  1995-02-27  |  2KB  |  87 lines

  1. ; -----------------------------------------------------------------------------
  2. ; SMM.ASM    Tests if central processor is SMMable.          Version 1.01
  3. ;
  4. ; Copyright(c) 1994 by B-coolWare.  Written by Bobby Z.
  5. ; This code is part of TMi0SDGL(tm) CPU/FPU Feature Detection Library.
  6. ; -----------------------------------------------------------------------------
  7. ; SMM = System Management Mode
  8. ;
  9. ; I thought that SMM is only AMD's 386 feature but it appeared that it also
  10. ; is supported in newer Intel and UMC chips.
  11.  
  12.     INCLUDE    HEADER.ASH
  13.  
  14.     .CODE
  15.  
  16.     PUBLIC    isSMMAble
  17.  
  18. int6H:            ; INT 6 (invalid instruction) trap hook
  19.     sub    ax,ax
  20.     sub    sp,4    ; restore stack and jump past offending instruction
  21.     popf
  22.     jmp    Past_invalid
  23.  
  24. check386    proc near
  25.     pushf
  26.     mov    ax,7000h
  27.     push    ax
  28.     popf
  29.     pushf
  30.     pop    ax
  31.     popf
  32.     and    ah,70h
  33.     jnz    @@1
  34.     stc
  35.     ret
  36. @@1:
  37.     clc
  38.     ret
  39.     endp
  40.  
  41. isSMMAble    PROC
  42.     call    check386
  43.     pushf
  44.     sub    ax,ax
  45.     popf
  46.     jc    @@Q
  47.     push    ds
  48.     mov    ax,3506h    ; get current INT 6 vector
  49.     int    21h
  50.     mov    ax,2506h    ; hook INT 6
  51.     mov    dx,offset int6H
  52.     push    cs
  53.     pop    ds
  54.     int    21h
  55.     pop    ds
  56.     sub    ax,ax        ; AX = 0
  57.     mov    cl,1        ; CL = 1
  58.     mov    dl,ds:[bx+si]    ; save byte at [bx+si] in dl
  59.  
  60. ;    The following code ( 0F12C1 ) is SMM instruction UMOV AL,CL that moves
  61. ;    data from/to main memory nevertheless the processor is in SMM or not.
  62.  
  63. ;    Cyrix chips doesn't generate INT 6 on this instruction. Instead, two
  64. ;    bytes 0F12 gets skipped and the next instruction appears to be
  65. ;    {rol word ptr [bx+si],0} ( C10000 ).
  66.  
  67.     db    0Fh
  68.     adc    al,cl
  69.     add     ds:[bx+si],al
  70. Past_Invalid:
  71.     mov    ds:[bx+si],dl    ; restoring possibly damaged data
  72.     push    ds
  73.     push    es
  74.     pop    ds
  75.     mov    dx,bx
  76.     push    ax
  77.     mov    ax,2506h    ; restore INT 6 vector
  78.     int    21h
  79.     pop    ax
  80.     pop    ds
  81. @@Q:
  82.     ret
  83.     ENDP
  84.  
  85.  
  86.     END
  87.